# -*- coding: utf-8 -*-
import turtle


def draw_tree(branch_length):

    if branch_length > 5:
        # 绘制右侧
        turtle.forward(branch_length)
        turtle.right(20)
        draw_tree(branch_length - 15)

        # 绘制左侧
        turtle.left(40)
        draw_tree(branch_length - 15)

        # 返回树枝节点
        turtle.right(20)
        turtle.back(branch_length)


def main():
    turtle.left(90)
    turtle.penup()
    turtle.back(30)
    turtle.pendown()
    turtle.color('red')

    branch_length = 100
    draw_tree(branch_length)

    turtle.exitonclick()


if __name__ == '__main__':
    main()